<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- building.qdoc -->
  <title>Building QtOpenCL</title>
  <link rel="stylesheet" type="text/css" href="style/style.css" />
  <script src="scripts/jquery.js" type="text/javascript"></script>
  <script src="scripts/functions.js" type="text/javascript"></script>
  <script src="./scripts/superfish.js" type="text/javascript"></script>
  <link rel="stylesheet" type="text/css" href="style/superfish.css" />  <script src="./scripts/narrow.js" type="text/javascript"></script>
  <link rel="stylesheet" type="text/css" href="style/narrow.css" />
  <!--[if IE]>
<meta name="MSSmartTagsPreventParsing" content="true">
<meta http-equiv="imagetoolbar" content="no">
<![endif]-->
<!--[if lt IE 7]>
<link rel="stylesheet" type="text/css" href="style/style_ie6.css">
<![endif]-->
<!--[if IE 7]>
<link rel="stylesheet" type="text/css" href="style/style_ie7.css">
<![endif]-->
<!--[if IE 8]>
<link rel="stylesheet" type="text/css" href="style/style_ie8.css">
<![endif]-->
</head>
<body class="" onload="CheckEmptyAndLoadList();">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left" valign="top" width="150"><img src="images/qt-logo.png" align="left" border="0" />&nbsp;&nbsp;<img src="images/qtopencl-logo.png" border="0" /></td>
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"> <a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="qtopencl-all-classes.html"><font color="#004faf">All Classes</font></a></td>
</table>              <li>Building QtOpenCL</li><div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#obtaining-the-source-code">Obtaining the source code</a></li>
<li class="level1"><a href="#required-qt-version">Required Qt version</a></li>
<li class="level1"><a href="#building-for-linux">Building for Linux</a></li>
<li class="level1"><a href="#building-for-macosx">Building for MacOSX</a></li>
<li class="level1"><a href="#building-for-windows">Building for Windows</a></li>
<li class="level1"><a href="#shadow-building">Shadow building</a></li>
<li class="level1"><a href="#checking-that-qtopencl-is-working">Checking that QtOpenCL is working</a></li>
<li class="level1"><a href="#generating-the-documentation">Generating the Documentation</a></li>
</ul>
</div>
<h1 class="title">Building QtOpenCL</h1>
<span class="subtitle"></span>
<!-- $$$building.html-description -->
<div class="descr"> <a name="details"></a>
<a name="obtaining-the-source-code"></a>
<h2>Obtaining the source code</h2>
<p>The QtOpenCL source code can be obtained from the external Qt git server: <a href="http://qt.gitorious.org/qt-labs/opencl">http://qt.gitorious.org/qt-labs/opencl</a></p>
<p>See the <a href="contrib.html">Contributing to QtOpenCL</a> page for more information on contributing to this project.</p>
<a name="required-qt-version"></a>
<h2>Required Qt version</h2>
<p>It is recommended that you use Qt 4.7, but the library will build with Qt 4.6&#x2e; The main missing feature is support for QGLBuffer in the <a href="qclcontextgl.html">QCLContextGL</a> class. QGLBuffer implements VBO support for QtOpenGL and is in Qt 4.7, but not 4.6&#x2e;</p>
<p>It is recommended that QtOpenCL be built against a developer build of Qt rather than an installed Qt SDK because the QtOpenCL library #include's private headers from the Qt sources. The library can be compiled against a Qt installation that does not have private headers, but the <a href="qclimage2d.html#drawImage">QCLImage2D::drawImage</a>() function will have reduced performance when painting into a raster-based QPixmap.</p>
<a name="building-for-linux"></a>
<h2>Building for Linux</h2>
<p>The top-level directory of the source tree contains a configure script that detects the system's OpenCL library and configures the build system of QtOpenCL to use it. The simplest way to configure and build is as follows:</p>
<pre class="highlightedCode brush: cpp">    ./configure -qmake path
    make</pre>
<p>The <tt>path</tt> should be the complete path to the <tt>qmake</tt> binary if it is not on the PATH. For example:</p>
<pre class="highlightedCode brush: cpp">    ./configure -qmake /usr/local/Trolltech/Qt-4.7.0/bin/qmake</pre>
<p>It is very important that the <tt>-qmake</tt> command-line option be supplied if you are cross-compiling for a device because the host system's <tt>qmake</tt> will not work.</p>
<p>By default, the build system assumes that the OpenCL headers are found in the normal system location for header files (usually <tt>/usr/include</tt>), and that the library to link against is called <tt>libOpenCL.so</tt>. These defaults can be overridden with command-line options to configure:</p>
<ul>
<li><tt>-Idir</tt> - Specify the directory that contains the includes <tt>&lt;CL/cl.h&gt;</tt>, <tt>&lt;CL/cl_gl.h&gt;</tt>, etc.</li>
<li><tt>-Ldir</tt> - Specify the directory that contains the <tt>libOpenCL.so</tt> library.</li>
<li><tt>-lname</tt> - Override the <tt>-lOpenCL</tt> default library name. This can also be used to add additional libraries; e.g&#x2e; &quot;<tt>-lOpenCL -lGLESv2</tt>&quot;.</li>
<li><tt>-no-openclgl</tt> - The OpenCL library does not have any of the functions that are needed to perform OpenGL interoperation. This will cause the sharing functionality of <a href="qclcontextgl.html">QCLContextGL</a> to be disabled. Applications can still use <a href="qclcontextgl.html">QCLContextGL</a>, but they will have reduced functionality. Normally this option will be detected automatically by configure.</li>
</ul>
<p>For example, if your OpenCL library is called <tt>libOCL.so</tt> installed under <tt>/opt/ocl/include</tt> and <tt>/opt/ocl/lib</tt>, and it does not support GL interoperation, you would configure as follows:</p>
<pre class="highlightedCode brush: cpp">    ./configure -qmake path -I/opt/ocl/include \
          -L/opt/ocl/lib -lOCL -no-openclgl</pre>
<a name="building-for-macosx"></a>
<h2>Building for MacOSX</h2>
<p>The instructions are similar to Linux:</p>
<pre class="highlightedCode brush: cpp">    ./configure -qmake path
    make</pre>
<p>It is assumed that the &quot;<tt>OpenCL</tt>&quot; framework has been installed to provide the OpenCL headers and libraries. If the OpenCL headers and libraries are provided by a different framework, it can be specified as follows:</p>
<pre class="highlightedCode brush: cpp">    ./configure -qmake path -fw OCL</pre>
<a name="building-for-windows"></a>
<h2>Building for Windows</h2>
<p>Currently there isn't an equivalent of configure for Windows. The alternative build instructions are as follows:</p>
<pre class="highlightedCode brush: cpp">    qmake opencl.pro
    nmake</pre>
<a name="shadow-building"></a>
<h2>Shadow building</h2>
<p>The configure script supports building the QtOpenCL library in a different directory than the source code. The following example builds the sources from <tt>$HOME/sources/opencl</tt> into <tt>$HOME/build/opencl</tt>:</p>
<pre class="highlightedCode brush: cpp">    mkdir $HOME/build/opencl
    cd $HOME/build/opencl
    $HOME/sources/opencl/configure -qmake path
    make</pre>
<a name="checking-that-qtopencl-is-working"></a>
<h2>Checking that QtOpenCL is working</h2>
<p>Once the library has been built, you can check if QtOpenCL is basically working by running the <a href="clinfo.html">clinfo</a> program, which should print out the capabilities of your OpenCL implementation:</p>
<pre class="highlightedCode brush: cpp">    $ export LD_LIBRARY_PATH=`pwd`/lib:$LD_LIBRARY_PATH
    $ util/clinfo/clinfo
    Platform ID       : 12289
    Profile           : FULL_PROFILE
    Version           : OpenCL 1.0
    ...</pre>
<p>The <tt>LD_LIBRARY_PATH</tt>, or its equivalent under other operating systems, needs to be set to point at the <tt>lib</tt> directory.</p>
<p>Another way to check that QtOpenCL is working is to run the <a href="vectoradd.html">Vector Addition Example</a>:</p>
<pre class="highlightedCode brush: cpp">    $ examples/opencl/vectoradd/vectoradd
    Answer is correct: 2048</pre>
<p>If you get a <tt>CL_INVALID_PLATFORM</tt>, <tt>CL_INVALID_VALUE</tt>, <tt>CL_DEVICE_NOT_AVAILABLE</tt>, or similar error, then you may need to modify <a href="qclcontext.html#create">QCLContext::create</a>() to locate the correct platform or device on your system.</p>
<p>You can also run the <tt>tests/auto/qcl/tst_qcl</tt> program to execute the QtOpenCL unit tests, which will check that the OpenCL implementation is operating in accordance with QtOpenCL's expectations.</p>
<p>When reporting bugs, it is recommended that you include the output of the <a href="clinfo.html">clinfo</a> program in the bug report.</p>
<a name="generating-the-documentation"></a>
<h2>Generating the Documentation</h2>
<p>From the top-level, type <tt>make docs</tt> to generate the documentation into the <tt>doc/html</tt> directory in the build tree. This will use the <tt>qdoc3</tt> binary from the Qt you used to build QtOpenCL. If that <tt>qdoc3</tt> binary does not exist, it will use the <tt>qdoc3</tt> binary on the PATH instead.</p>
<p><a href="index.html">Return to Home</a></p>
</div>
<!-- @@@building.html -->
<p /><address><hr /><div align="center">
<table width="100%" cellspacing="0" border="0"><tr class="address">
<td align="left">Copyright &copy; 2010 Nokia Corporation</td>
<td align="right">QtOpenCL Documentation</td>
</tr></table></div></address>  <script src="scripts/functions.js" type="text/javascript"></script>
  <script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-4457116-5']);
  _gaq.push(['_trackPageview']);
  (function() {
  var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
  ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
  </script>
</body>
</html>
